<html>
<head><meta charset="utf-8"><title>using miri without cargo · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html">using miri without cargo</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="187946163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/187946163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#187946163">(Feb 11 2020 at 19:40)</a>:</h4>
<p>Hi, I have a project where I use my own test suite harness (think compile-test but less clever). I'd like to run these tests under miri but from what I can see, cargo-miri assumes that binaries are known by cargo (either via <code>[[bin]]</code> in <code>Cargo.toml</code> or by existing in <code>src/bin/</code>. Instead, we just have a large dir of independent source files, a bit like the <code>test/</code> dir in rustc. Is it possible to setup and compile things for miri using <code>rustc</code> so that my own test harness (and not cargo-miri)  can compile each target independently and dispatch it to <code>cargo-miri run</code>? Thanks!</p>



<a name="187958995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/187958995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#187958995">(Feb 11 2020 at 21:42)</a>:</h4>
<p>You can use the <code>miri</code> binary instead. I believe it is a drop in replacement for the <code>rustc</code> binary.</p>



<a name="188051567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/188051567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#188051567">(Feb 12 2020 at 20:44)</a>:</h4>
<p>Thanks Bjorn! <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="188088521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/188088521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#188088521">(Feb 13 2020 at 09:00)</a>:</h4>
<p>indeed. :) using this "driver" directly is not very well documented and the flags are less stable, but it should work. if you have any questions, feel free to ask here or open an issue.</p>



<a name="188129047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/188129047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#188129047">(Feb 13 2020 at 17:27)</a>:</h4>
<p>Thanks <span class="user-mention" data-user-id="120791">@RalfJ</span>, I'm having a little difficulty using the driver because the file I want to test depends on a crate. Is there a way to use <code>cargo miri</code> to build the crate with the relevant miri flags, and then divert to the driver to actually run the file? Maybe even I could use <code>cargo rustc</code> with the same toolchain as the driver and pass in the relevant flags as arguments?</p>



<a name="188153428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/188153428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#188153428">(Feb 13 2020 at 21:24)</a>:</h4>
<p><span class="user-mention" data-user-id="223286">@Jake Hughes</span></p>
<blockquote>
<p>Is there a way to use cargo miri to build the crate with the relevant miri flags, and then divert to the driver to actually run the file?</p>
</blockquote>
<p>well that's exactly what <code>cargo miri</code> does...^^</p>



<a name="188153454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/188153454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#188153454">(Feb 13 2020 at 21:24)</a>:</h4>
<p>you could do <code>cargo miri -v</code> to make it show you all the flags for calling the driver the right way</p>



<a name="188153750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/188153750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#188153750">(Feb 13 2020 at 21:27)</a>:</h4>
<p>it'll show something like</p>
<div class="codehilite"><pre><span></span>     Running `/home/r/.cargo/bin/cargo-miri rustc --crate-name cargo_miri_test --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 cargo-miri-marker-begin cargo-miri-marker-end -C metadata=2eab38112672c0a9 -C extra-filename=-2eab38112672c0a9 --out-dir /home/r/src/rust/miri/test-cargo-miri/target/debug/deps -C incremental=/home/r/src/rust/miri/test-cargo-miri/target/debug/incremental -L dependency=/home/r/src/rust/miri/test-cargo-miri/target/debug/deps --extern byteorder=/home/r/src/rust/miri/test-cargo-miri/target/debug/deps/libbyteorder-6f03af6f96c10631.rlib`
</pre></div>



<a name="188162673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/188162673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#188162673">(Feb 13 2020 at 23:13)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span>  Ah I understand. Unfortunately I have quite a lot of crates that would need manually compiling with the driver this way that it's not really feasible. Is there a flag I can pass to <code>cargo-miri</code> that would let me build the artefacts for miri but not run them? That way I could just pre-build them and link them all on the command line at once with the driver.</p>



<a name="188185850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/188185850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#188185850">(Feb 14 2020 at 08:05)</a>:</h4>
<p>Hm, no... probably the best you can do is add a hack <a href="https://github.com/rust-lang/miri/blob/49aafadfb870f172a14e3428a5e05d57d27fb080/src/bin/cargo-miri.rs#L487" target="_blank" title="https://github.com/rust-lang/miri/blob/49aafadfb870f172a14e3428a5e05d57d27fb080/src/bin/cargo-miri.rs#L487">here</a> to just skip the binary you do not want to run</p>



<a name="188185919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/188185919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#188185919">(Feb 14 2020 at 08:06)</a>:</h4>
<p>also there's no "linking" so I dont entirely follow your question</p>



<a name="188185971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/188185971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#188185971">(Feb 14 2020 at 08:07)</a>:</h4>
<p>I also finally figured out the debug flag I actually wanted to recommend: <code>cargo miri run -- -v</code></p>



<a name="188185987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/188185987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#188185987">(Feb 14 2020 at 08:07)</a>:</h4>
<p>the number of dependencies doesnt matter, this will just build all of them and then run the first binary (and fail, you said), but it'll print the invocation so you can make it run the 2nd binary instead</p>



<a name="188238683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/using%20miri%20without%20cargo/near/188238683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/using.20miri.20without.20cargo.html#188238683">(Feb 14 2020 at 19:35)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> The penny has dropped -- I see what you mean now. Thanks for the help!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>